<?php

namespace app\api\model;

use app\api\service\Api;
use think\Db;
use think\Request;

class BackListCompanyModel extends Api
{
    protected static $instance;

    public function __construct(Request $request = null)
    {
        parent::__construct($request);
    }

    public static function getInstance()
    {
        if (is_null(self::$instance))
        {
            self::$instance = new static();
        }
        return self::$instance;
    }

    /**
     * 添加记录
     */
    public function insert($data)
    {
        return Db::name('backlist_company')->insert($data);
    }

    /**
     * 更新记录
     */
    public function update($where, $data)
    {
        return Db::name('backlist_company')->where($where)->update($data);
    }

    /**
     * 获取多条记录
     */
    public function select($where, $field = '*', $start = 0, $limit = 100000, $order = 'c_time DESC')
    {
        return Db::name('backlist_company')->where($where)->limit($start, $limit)->order($order)->field($field)->select();
    }

    /**
     * 获取一条记录
     */
    public function find($where, $field = '*')
    {
        return Db::name('backlist_company')->where($where)->field($field)->find();
    }

    /**
     * 获取总数
     */
    public function count($where)
    {
        return Db::name('backlist_company')->where($where)->count();
    }

    /**
     * 删除记录
     */
    public function delete($where)
    {
        return Db::name('backlist_company')->where($where)->delete();
    }
}